using Bardent.Weapons.Components.ComponentData;
using Bardent.Weapons.Components.ComponentData.AttackData;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Bardent.Weapons.Components
{

    

    public class WeaponMovement : WeaponComponent<MovementData,AttackMovement>
    {
        private Movement coreMovement;

        private Movement CoreMovement => coreMovement ?? Core.GetCoreComponent<Movement>(ref coreMovement);

        //private MovementData data;

        private void HandleStartMovement()
        {
            //var currentAttackData = data.AttackData[weapon.CurrentAttackCounter];
            CoreMovement.SetVelocity(currentAttackData.Velocity,currentAttackData.direction,CoreMovement.FacingDirection);
        }

        private void HandleStopMovement()
        {
            CoreMovement.SetVelocityZero();
        }

        //protected override void Awake()
        //{
        //    base.Awake();
        //    data = weapon.Data.GetData<MovementData>();
        //}

        protected override void Start()
        {
            base.Start();
            eventHandler.OnStartMovement += HandleStartMovement;
            eventHandler.OnStopMovement += HandleStopMovement;
        }

        protected override void OnDestroy()
        {
            base.OnDestroy();
            eventHandler.OnStartMovement -= HandleStartMovement;
            eventHandler.OnStopMovement -= HandleStopMovement;
        }
    }
}
